package com.example.stu.controller;

import com.example.stu.entity.PageResult;
import com.example.stu.entity.Result;
import com.example.stu.entity.res.StuSelectDormitoryVo;
import com.example.stu.service.DormitoryService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Date: 2021/3/4
 * @Author: 黄先军
 * @Description:
 */
@RestController
@RequestMapping("/dormitory")
public class DormitoryController {
    @Autowired
    private DormitoryService dormitoryService;

    /**
     *根据学生的学号查找到学生可以选择的寝室
     * @param id
     * @return
     */
    @RequestMapping("findDormitoryByStuId")
    public PageResult findDormitoryByStuId(Integer id) {
        return dormitoryService.findDormitoryByStuId(id);
    }

    /**
     * 学生选择寝室入住
     * @param stuSelectDormitoryVo
     * @return
     */
    @PostMapping("selectDormitory")
    public Result selectDormitory(@RequestBody StuSelectDormitoryVo stuSelectDormitoryVo){
        return dormitoryService.selectDormitory(stuSelectDormitoryVo);
    }
}
